<?php
/* -----------------------------------------------------------------
 *                          Aveghe Installer
 * -----------------------------------------------------------------
 * Aveghe Installer: made your web application installation easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe Installer is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe Installer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

error_reporting (E_STRICT);
set_include_path(get_include_path().PATH_SEPARATOR.'../lib');

require_once('Zend/Loader.php');

Zend_Loader::registerAutoload();

// session starts
$avegheNS = new Zend_Session_Namespace('avegheNS');

$domain        = '';
$dbHost        = '';
$dbUsername    = '';
$dbName        = '';
$dbTablePrefix = 'aveghe_';

$message       = '';

if(isset($avegheNS->report))
	{
		$report = $avegheNS->report;
		unset($avegheNS->report);
		
		$domain        = $report['domain'];
		$dbHost        = $report['dbHost'];
		$dbUsername    = $report['dbUsername'];
		$dbName        = $report['dbName'];
		$dbTablePrefix = $report['dbTablePrefix'];	
		$message       = $report['message'];
	}

$theme = "resources/themes/aveghe/template.xhtml";
$meta  = "<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />\n";

if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) 
	header("Content-type: application/xhtml+xml");
else
	{
		header("Content-type: text/html");
		$meta = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
	}

$content = <<< CONTENT

	<form action="install.php" method="post">
		<fieldset>
			<legend>Installazione</legend>
			<p class="borderTop">
				<label for="domain">Dominio</label>
				<input id="domain" name="domain" type="text" value="$domain" />
			
				<label for="dbHost">Indirizzo server MySQL</label>
				<input id="dbHost" name="dbHost" type="text" value="$dbHost" />
				
				<label for="dbUsername">Utente del server MySQL</label>
				<input id="dbUsername" name="dbUsername" type="text" value="$dbUsername" />
				
				<label for="dbPassword">Password per il server MySQL</label>
				<input id="dbPassword" name="dbPassword" type="password" />
				
				<label for="dbName">Nome del data base</label>
				<input id="dbName" name="dbName" type="text" value="$dbName" />
				
				<label for="dbTablePrefix">Prefisso delle tabelle</label>
				<input id="dbTablePrefix" name="dbTablePrefix" type="text" value="$dbTablePrefix" />
				
				<input class="submit" type="submit" value="Installa" />
			</p>
		</fieldset>
	</form>

CONTENT;

include($theme);
?>